'use strict';
const Controller = require('../base/base.js')
class HomeController extends Controller {
  // 登录接口
  /* sql,提示文案,返回码，http状态码
   @pamar resData(sql, msg, 200, 200)
  */
  async login() {
    const { ctx, app } = this;
    let sql = await this.service.home.login(ctx.request.body)
    ctx.body = await this.resData(sql)
  }
  async userList() {
    const { ctx, app } = this;
    let sql = await this.service.home.userList({}, 'select')
    ctx.body = await this.resData(sql)
  }
  async adduserList() {
    const { ctx, app } = this;
    let sql = await this.service.home.userList(ctx.request.body, 'add')
    ctx.body = await this.resData(sql)
  }
  async deluserList() {
    const { ctx, app } = this;
    let sql = await this.service.home.userList(ctx.request.body, 'del')
    ctx.body = await this.resData(sql)
  }
  async updataUserList() {
    const { ctx, app } = this;
    let sql = await this.service.home.userList(ctx.request.body, 'updata')
    ctx.body = await this.resData(sql)
  }
  async index() {
    const { ctx, app } = this;
    let sql = await this.service.home.index(ctx.request.body)
    ctx.body = await this.resData(sql, '成功', 200, 200)
  }
}

module.exports = HomeController;
